﻿@model Matrix.MaKaYunShang.Model.CommodityGift

@{
    ViewBag.Title = "添加赠品";
    ViewBag.PathToBtn = "/CommodityGift/List";
    ViewBag.TextBtn = "返回至列表";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                赠品信息
            </div>
            <div class="panel-body">
                <div class="row">
                    @using (Html.BeginForm("Create", "CommodityGift", FormMethod.Post, new { id = "frmCreate", enctype = "multipart/form-data" }))
                    {
                        @Html.AntiForgeryToken()
                        @Html.ValidationSummary(true)

                        <div class="col-lg-12">
                            <fieldset>
                                <div class="form-group col-md-6">
                                    <label>赠品</label>
                                    <div class="input-group">
                                        @Html.DropDownList("GiftCommodityLibId", (IEnumerable<SelectListItem>)ViewBag.Commodities, new { @class = "form-control" })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label>绑定的商品</label>
                                    <div class="input-group">
                                        @Html.DropDownList("BelongToCommodityLibId", (IEnumerable<SelectListItem>)ViewBag.Commodities, new { @class = "form-control" })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label>赠品数量</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.GiftQuantity, new { @class = "form-control", placeholder = "赠品数量" })
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label>剩余库存</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.LeftQuantity, new { @class = "form-control", placeholder = "剩余数量" })
                                        <span class="input-group-addon red"></span>
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label>用户可得赠品频率</label>
                                    <div>
                                        每
                                        @Html.TextBoxFor(model => model.TimeSpanCount, new { @class = "form-control", placeholder = "时间长度", style = "width: 85px;display: inline;" })
                                        @Html.DropDownList("TimeSpanType", (IEnumerable<SelectListItem>)ViewBag.SeletTimeSpanType, new { @class = "form-control", style = "width: 80px; display: inline;" })
                                        @Html.TextBoxFor(model => model.ConsumerGetTotalTimes, new { @class = "form-control", placeholder = "次数", style = "width: 80px;display: inline;" })
                                        次
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <button id="btnSave" type="submit" class="btn btn-primary">确定并保存</button>
                                    <button id="btnReset" type="reset" class="btn btn-outline btn-primary">清空设置</button>
                                </div>
                            </fieldset>
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>
</div>

@section javascript{
    <script type="text/javascript">
        $(function() {
            $("#frmCreate").validate({
                rules: {
                    GiftQuantity: { required: true, digits: true },
                    LeftQuantity: { digits: true },
                    TimeSpanCount: { required: true, digits: true, min: 1 },
                    ConsumerGetTotalTimes: { required: true, digits: true, min: 1 }
                },
                messages: {
                    GiftQuantity: { required: "请填写赠品数量" }
                },
                submitHandler: function(form) {
                    form.submit();
                }
            });
        });

    </script>
}